<template>
	<!-- 拟态弹窗 -->
	<view class="">
		<u-popup  :show="isShow"  :mode="mode" round="10">
			<view class="popView" :style="'width:'+popupWidth">
				
				<view class="title">
					<text v-text="title"></text>
				</view>
				<view class="main">
					<slot></slot>
					<view v-if="content!=''" class="content">
						<text v-text="content"></text>
					</view>
					<view v-if="placeholder!=''"  class="input" hi>
						<input type="text" placeholder-style="#C1C1C1" @click="hiddenPlaceholder" v-model="value" :placeholder="hiddenText?'':placeholder" />
					</view>
				</view>
				<view class="btns" v-if="!isBorderBtn"> 
					<view class="cancel" @click="btnClick('cancel')">
						<text>取消</text>
					</view>
					<view class="confim" :style="activeColor ? 'background:'+activeColor : ''" @click="btnClick('confim')">
						<text>{{confirmText}}</text>
					</view>
				</view>
				<view class="btns" v-if="isBorderBtn">
					<view class="cancel borderBtn" @click="btnClick('cancel')">
						<text>取消</text>
					</view>
					<view class="confim borderBtn" :style="activeColor ? `background:${activeColor}` : ''" @click="btnClick('confim')">
						<text>{{confirmText}}</text>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
	
</template>

<script>
	export default{
		props:{	
			isBorderBtn:{
				default : false,
				type  : Boolean,
			},
			isShow:{
				default : true,
				type  : Boolean,
			},
			//标题
			title:{
				default : '',
				type  : String,
			},
			content:{
				default:'',
				type:String,
			},
			placeholder:{
				default:'',
				type:String
			},
			//返回得方法名
			fun:{
				default:'popReturn',
				type:String
			},
			activeColor:{
				default : '#109078',
				type: String,
			},
			confirmText:{
				default : '确认',
				type: String,
			},
			mode:{
				default : 'center',
				type: String,
			},
			popupWidth:{
				default : '620rpx',
				type: String,
			}
		},
		data(){
			return {
				value:'',
				hiddenText:false
			}
		},
		methods:{
			btnClick(e){
				let data={ 
					'btn':e,
					'val':this.value
				};
				this.$emit(`${this.fun}`,data)
				if(e=='cancel'){
					this.$emit('cancel')
				}else if(e=='confim'){
					this.$emit('confirm')
				}
				this.hiddenText=false;
			},
			hiddenPlaceholder(){
				this.hiddenText=true;
			}
		},
	
	}
</script>

<style lang="scss" scoped>
	.coverBg{
		position: fixed;
		top: 0;
		left: 0;
	}
	.popView{
		// width: 620rpx;
		text-align: center;
		border-radius: 20rpx;
		overflow: hidden;
		.title{
			padding: 50rpx 0 30rpx 0;
			font-weight: 600;
			font-size: 36rpx;
		}
		.main{
			padding: 20rpx 0;
			margin-bottom: 30rpx;
			font-size: 36rpx;
			view{
				width: 75%;
				margin: 0 auto;
				input{
					height: 90rpx;
					background-color: #F6F6F6;
				}
			}
			input{
				color: #000;
			}
		}
		
		.btns{
			width: 100%;
			display: flex;
			overflow: hidden;
			margin: 0 auto;
			padding: 0;
			border-bottom-left-radius: 20rpx;
			border-bottom-right-radius: 20rpx;
			.borderBtn{
				border-radius: 43rpx;
				margin: 0 30rpx 20rpx;
				&:nth-child(1){
					flex: 0.7;
					margin-right: 0;
				}
			}
			view{
				flex: 1;
				height: 86rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				// padding: 30rpx 0;
			}
			.cancel{
				background-color: #F4F4F4;
				color: #999;
			}
			.confim{
				background-color: #EC3D66;
				color: #fff;
			}
		}
	}

</style>
